//
//  NSString+Utils.m
//  ifangchou
//
//  Created by Bias.Xie on 15/9/23.
//  Copyright (c) 2015年 ifangchou. All rights reserved.
//

#import "NSString+Utils.h"
#import <CommonCrypto/CommonDigest.h>
@implementation NSString (Utils)


+ (NSString *)stringWithInt32:(int32_t)number{
    return [NSString stringWithFormat:@"%i",number];
}

+ (NSString *)stringWithInt64:(int64_t)number{
    return [NSString stringWithFormat:@"%lli",number];
}

+ (int32_t)int32WithString:(NSString *)string{
    return (int32_t)string.longLongValue;
}

+ (int64_t)int64WithString:(NSString *)string{
    return string.longLongValue;
}

- (int32_t)int32{
    return [NSString int32WithString:self];
}

- (int64_t)int64{
    return [NSString int64WithString:self];
}

+ (NSString *)changeDateFormate:(NSString*)strDate
{
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    NSDate* date = [formatter dateFromString:strDate];
    [formatter setDateFormat:@"yyyy-MM-dd HH:mm"];
    NSString *dateTime = [formatter stringFromDate:date];
    return dateTime;
}

+ (NSString *)titleForProjectStatus:(NSInteger)status{
    NSString *title = @"未知";
    if( status == -1 ){
        title = @"已下线";
    }
    else if( status == 0 ){
        title = @"待发布";
    }
    else if( status == 1 ){
        title = @"预约中";
    }else if( status == 2 ){
        title = @"抢购中";
    }else if( status == 3 ){
        title = @"已筹满";
    }else if( status == 4 ){
        title = @"已结束";
    }
    return title;
}

+ (NSString *)titleForNetworkDisconnected{
    return @"网络不通畅，请稍后尝试";
}

+(NSString*)omittedByLength:(NSInteger)len andTagString:(NSString*)tagStr{
    NSString* omittStr = [[NSString alloc]init];
    for (int i = 0; i<len; i++) {
        omittStr = [omittStr stringByAppendingString:tagStr];
    }
    return omittStr;
}
@end
